<?php
namespace router;

use app\common\middleware\AllowOriginMiddleware;
use app\common\middleware\UserTokenMiddleware;
use think\facade\Route;

Route::group(config('admin.api_prefix','api'),function (){
    //强制登录
    Route::group('',function (){
        Route::group('user',function (){
            Route::group('',function (){
                Route::get('user_info','/userInfo');
                Route::post('focus','/focus');
                Route::get('focusLst','/focusLst');
                Route::get('fansLst','/fansLst');
                Route::post('update','/update');
                Route::post('phone','/updatePhone');
                Route::get('phone_code','/updatePhoneCode');
                Route::get('shareUser','/shareUser');
                Route::get('shareUser','/shareUser');
                Route::get('shareUser','/shareUser');
            })->prefix('api.user.User');

            Route::get('auth','api.info.AdTask/adConfig');
            Route::post('member/openMember','api.user.User/openMember');
            Route::get('member/searchUser','api.user.User/searchUser');
            Route::get('member/lst','api.user.User/memberLst');
        });


        Route::group('ad_task',function (){
            Route::group('package',function (){
                Route::get('lst', '/packageLst');
            })->prefix('api.info.AdTask');

            Route::group('',function (){
                Route::post('create', '/create');
                Route::post('update/:id', '/update');
                Route::post('record', '/record');
                Route::post('share/:id', '/share');
                Route::get('lst', '/lst');
                Route::get('user_lst', '/userLst');
                Route::get('index', '/index');
            })->prefix('api.info.AdTask');

        });



        Route::get('user_balance/lst','api.user.Balance/lst');


        Route::group('user_extract',function (){
            Route::group('',function (){
                Route::get('lst','/lst');
                Route::post('create','/create');

            })->prefix('api.user.Extract');
        });


        Route::group('lawyer',function (){
            Route::group('',function (){
                Route::post('require','/require');
                Route::post('update_info','/updateInfo');
                Route::get('lawyer_info','/lawyerInfo');
                Route::get('lawyer_detail/:lawyer_id','/lawyerDetail');
                Route::get('send_code','/sendCode');
            })->prefix('api.lawyer.Lawyer');
        });


//        Route::group('member',function (){
//            Route::group('',function (){
//                Route::get('lst','/lst');
//                Route::get('info','/info');
//                Route::post('open/:id','/open');
//            })->prefix('api.member.Member');
//        });


        Route::group('order',function (){
            Route::group('',function (){
                Route::post('create','/create');
                Route::post('check','/check');
                Route::get('lst','/lst');
                Route::get('detail/:id','/detail');
                Route::get('config','/config');
            })->prefix('api.info.Order');
        });


        Route::group('question',function (){
            Route::group('',function (){
                Route::post('create/:info_id','/create');
                Route::get('detail/:info_id','/detail');
            })->prefix('api.info.Question');
        });

        Route::group('article',function (){
            Route::get('detail/:id', '/detail')->name('gameCount');
            Route::get('userLst', '/userLst')->name('gameCount');
        })->prefix('api.info.Article');


        Route::group('map_task',function (){
            Route::get('get_data', '/getData');
            Route::get('lst', '/lst');
            Route::get('record', '/record');
            Route::get('recordDetail/:id', '/recordDetail');
            Route::post('recordCopy/:id', '/recordCopy');
            Route::get('recordFilterData', '/recordFilterData');
        })->prefix('api.info.MapTask');



    })->middleware(UserTokenMiddleware::class,true);


    //非强制登录
    Route::group('',function (){
        Route::group('map_task',function (){
            Route::get('location2Address', '/location2Address');
        })->prefix('api.info.MapTask');


        Route::group('ad_task',function (){
            Route::get('get_time', '/getTime');
            Route::get('detail/:id', '/detail');
        })->prefix('api.info.AdTask');


        Route::group('lawyer',function (){
            Route::group('',function (){
                Route::post('lst','/lst');
            })->prefix('api.lawyer.Lawyer');
        });


        Route::group('article',function (){
            Route::get('lst', '/lst')->name('userLst');
        })->prefix('api.info.Article');


        Route::group('swiper',function (){
            Route::group('',function (){
                Route::get('lst','/getSwiperAll');
                Route::get('detail/:id','/detailSwiper');
            })->prefix('admin.Common');
        });


        Route::group('info',function (){
            Route::group('',function (){
                Route::get('questionIndexLst','/questionIndexLst');
            })->prefix('api.info.Info');
        });


        Route::get('share_code','api.Auth/shareCode');

        Route::get('shop_lst','api.info.Order/shopLst');

        Route::get('get_case_type','admin.Common/getCaseType');
        Route::get('get_main_do','admin.Common/getMainDo');
        Route::get('get_article_agreement','admin.Common/get_article_agreement');

    })->middleware(UserTokenMiddleware::class,false);


    Route::group('',function (){
       Route::post('wx_auth','api.Auth/wechatLogin');
       Route::post('imgCode','api.Auth/imgCode');
//       Route::post('phone_auth','api.Auth/phoneAuth');
        Route::get('phone_auth_code','api.Auth/phoneAuthCode');
       Route::get('codeGetOpenid','api.Auth/codeGetOpenid');

       Route::post('upload/:field','api.Common/upload');
       Route::get('city_list','admin.system.City/lst');
       Route::get('jsConfig','api.Common/jsConfig');
    });

    Route::get('agreement','admin.Common/getAgreement');

    Route::get('test','api.info.Question/test');

})->middleware(AllowOriginMiddleware::class);